#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;

int main()
{
    int t1[8], t2[8];
    int maxDay = 1;
    int maxTime = 0;
    for (int i = 1; i <= 7; i++)
    {
        cin >> t1[i] >> t2[i];
        if (t1[i] + t2[i] > 8)
        {
            if (t1[i] + t2[i] > maxTime)
                maxTime = t1[i] + t2[i];
            maxDay = i;
        }
    }
    for (int i = 1; i <= 7; i++)
    {
        if (maxTime == t1[i] + t2[i])
        {
            maxDay = i;
            break;
        }
    }
    if (maxTime == 0)
        cout << 0;
    else
        cout << maxDay;
    return 0;
}
